import { BrowserWindow } from 'electron';

export class WindowResizer {
  private readonly browserWindow: BrowserWindow;
  private readonly MIN_HEIGHT: number;

  constructor(browserWindow: BrowserWindow, MIN_HEIGHT: number) {
    this.browserWindow = browserWindow;
    this.MIN_HEIGHT = MIN_HEIGHT;
  }

  public increaseWindowSize(increaseBy: number) {
    const [currentWidth, currentHeight] = this.browserWindow.getSize();
    this.browserWindow.setSize(currentWidth, Math.max(this.MIN_HEIGHT, currentHeight+increaseBy));
  }

  public decreaseWindowSize(decreaseBy: number) {
    const [currentWidth, currentHeight] = this.browserWindow.getSize();
    this.browserWindow.setSize(currentWidth, Math.max(this.MIN_HEIGHT, currentHeight - decreaseBy));
  }
}
